互億無(wú)線(xiàn) · 文檔中心

短信驗(yàn)證碼/通知 - 代碼示例


GO對(duì)接驗(yàn)證碼短信接口DEMO示例
本文為您提供了GO語(yǔ)言版本的驗(yàn)證碼短信接口對(duì)接DEMO示例

驗(yàn)證碼/通知短信接口文檔 點(diǎn)擊下載

驗(yàn)證碼/通知短信接口接入指南 點(diǎn)擊訪(fǎng)問(wèn)

注冊(cè)/登錄頁(yè)圖形驗(yàn)證工具 點(diǎn)擊訪(fǎng)問(wèn)


//接口類(lèi)型:互億無(wú)線(xiàn)觸發(fā)短信接口,支持發(fā)送驗(yàn)證碼短信、訂單通知短信等。
// 賬戶(hù)注冊(cè):請(qǐng)通過(guò)該地址開(kāi)通賬戶(hù)https://user.ihuyi.com/new/register.html
// 注意事項(xiàng):
//(1)調(diào)試期間,請(qǐng)使用用系統(tǒng)默認(rèn)的短信內(nèi)容:您的驗(yàn)證碼是:【變量】。請(qǐng)不要把驗(yàn)證碼泄露給其他人。
//(2)請(qǐng)使用 APIID 及 APIKEY來(lái)調(diào)用接口,可在會(huì)員中心獲?。?
//(3)該代碼僅供接入互億無(wú)線(xiàn)短信接口參考使用,客戶(hù)可根據(jù)實(shí)際需要自行編寫(xiě);
 
package main
 
import (
    "crypto/md5"
    "encoding/hex"
    "fmt"
    "io/ioutil"
    "net/http"
    "net/url"
    "strconv"
    "strings"
    "time"
)
 
func GetMd5String(s string) string {
    h := md5.New()
    h.Write([]byte(s))
    return hex.EncodeToString(h.Sum(nil))
}
func main() {
    v := url.Values{}
    _now := strconv.FormatInt(time.Now().Unix(), 10)
    //fmt.Printf(_now)
    _account := "cf_xxxxxxx"http://查看用戶(hù)名 登錄用戶(hù)中心->驗(yàn)證碼通知短信>產(chǎn)品總覽->API接口信息->APIID
    _password := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" //查看密碼 登錄用戶(hù)中心->驗(yàn)證碼通知短信>產(chǎn)品總覽->API接口信息->APIKEY
    _mobile := "136xxxxxxxx"
    _content := "您的驗(yàn)證碼是:9552。請(qǐng)不要把驗(yàn)證碼泄露給其他人。"
    v.Set("account", _account)
    v.Set("password", GetMd5String(_account+_password+_mobile+_content+_now))
    v.Set("mobile", _mobile)
    v.Set("content", _content)
    v.Set("time", _now)
    body := strings.NewReader(v.Encode()) //把form數(shù)據(jù)編下碼
    client := &http.Client{}
    req, _ := http.NewRequest("POST", "http://106.ihuyi.com/webservice/sms.php?method=Submit&format=json", body)
 
    req.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value")
    //fmt.Printf("%+v\n", req) //看下發(fā)送的結(jié)構(gòu)
 
    resp, err := client.Do(req) //發(fā)送
    defer resp.Body.Close()     //一定要關(guān)閉resp.Body
    data, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(data), err)
}

現(xiàn)在注冊(cè),即享新用戶(hù)禮包!

在線(xiàn)咨詢(xún)
電話(huà)咨詢(xún)

服務(wù)熱線(xiàn):

4008 808 898

服務(wù)熱線(xiàn)(工作時(shí)間):

4008 808 898

業(yè)務(wù)咨詢(xún)(非工作時(shí)間):

售后咨詢(xún)(非工作時(shí)間):

驗(yàn)證碼已發(fā)送到您的手機(jī),請(qǐng)查收!

輸入驗(yàn)證碼后,點(diǎn)擊“開(kāi)通體驗(yàn)賬戶(hù)”按鈕可立即開(kāi)通體驗(yàn)賬戶(hù)。

收不到短信驗(yàn)證碼?
互億無(wú)線(xiàn)不提供接碼服務(wù),接碼用戶(hù)請(qǐng)勿點(diǎn)擊開(kāi)通按鈕。
×